/* Copyright (c) 2004-2024 peigen.info. All rights reserved. */

package info.peigen.hotpot.business.product.manage.controller;

import info.peigen.hotpot.business.product.manage.form.ProductBrandManageCreateForm;
import info.peigen.hotpot.business.product.manage.form.ProductBrandManageEditForm;
import info.peigen.hotpot.business.product.manage.form.ProductBrandManageSearchForm;
import info.peigen.hotpot.business.product.manage.info.ProductBrandManageInfo;
import info.peigen.hotpot.business.product.manage.service.ProductBrandManageService;
import info.peigen.hotpot.common.core.result.PageResult;
import info.peigen.hotpot.common.core.result.manage.WebResult;
import info.peigen.hotpot.component.data.repository.beetlsql.filter.ManageDataAspect;
import org.noear.solon.annotation.Body;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Mapping;
import org.noear.solon.validation.annotation.Valid;

/**
 * <b>(ProductBrandManageController)</b>
 * 管理后台 "商品品牌"控制器
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2024-05-02
 */
@SuppressWarnings({"rawtypes", "unused", "unchecked"})
@Valid
@Controller
@Mapping("hotpot/productBrand")
public class ProductBrandManageController {
    @Inject
    ProductBrandManageService productBrandManageService;

    @Mapping("page")
    @ManageDataAspect
    WebResult page(@Body ProductBrandManageSearchForm form) {
        PageResult<ProductBrandManageInfo> page = productBrandManageService.page(form);
        return WebResult.setSuccessResult().setInfo(page);
    }

    @Mapping("create")
    @ManageDataAspect
    WebResult create(@Body ProductBrandManageCreateForm form) {
        productBrandManageService.create(form);
        return WebResult.setSuccessResult();
    }

    @Mapping("edit")
    @ManageDataAspect
    WebResult edit(@Body ProductBrandManageEditForm form) {
        productBrandManageService.edit(form);
        return WebResult.setSuccessResult();
    }

    @Mapping("remove")
    @ManageDataAspect
    WebResult remove(@Body ProductBrandManageSearchForm form) {
        productBrandManageService.remove(form.getId());
        return WebResult.setSuccessResult();
    }
}
